{% extends "_layout.html" %}
{% import "component/statistics.njk" as statistics %}

{# 样式代码 #}
{% block style %}
<title>已选题目</title>
<style type="text/css">
    .mui-content{padding-bottom: 65px;}
    .mui-content>.mui-table-view:first-child{margin: 0;}
    .mui-table-view-cell{ padding: 16px 15px;}
    .mui-table-view-cell>a:not(.mui-btn){margin: -16px -15px;}
    body{
        overflow-x: hidden;
    }
</style>
{% endblock %}

{# bodyd代码#}
{% block body %}
<div class="mui-content">
    <!--单选题-->
    {% for item in data.list %}
    <div class="mui-card">
        <div class="mui-card-content">
            <div class="mui-card-content-inner">
                <a href="arrhomework4?id={{item.id}}"><span>[单选题]</span>{{item.content}}
                    <div class="mb-subjects">
                        {%for item2 in item.choiceDTOs%}
                        <p>{{item2.serialNumber}}.{{item2.content}}</p>
                        {%endfor%}
                    </div>
                    <form  class="mui-input-group" action="">
                        <div class="mui-input-row mui-checkbox mb-sub-row">
                            <label class="mb-box">难度 {{item.serialNumber}}</label>
                            <input name="checkbox1" data-id="{{item.id}}" type="checkbox" onclick="js_on(this)">
                        </div>
                    </form>
                </a>
            </div>
        </div>
    </div>
    {%endfor%}
</div>


<!--保存作业、去发布-->
<nav class="mui-bar mui-bar-tab mb-subject-tab">

    <!--<a class="mui-tab-item1 mui-active" href="javascript:void(0);">-->
        <!--<span class="mui-tab-label">保存作业</span>-->
    <!--</a>-->
    <a class="mui-tab-item1" href="javascript:void(0)" onclick="js_tj()">
        <span class="mui-tab-label">去发布（<span id="number">0</span>）</span>
    </a>
</nav>
{% endblock %}

{#js代码#}
{% block js %}
<script src="js/jquery-2.1.1.min.js"></script>
<script>
    var data = $(".mui-card").html();
    var data1 = data.replace(/&lt;/g,'<');
    var data2 = data1.replace(/&gt;/g,'>');
    $(".mui-card").html(data2);


    var arr = [];
    var n = 0;

    function js_on(e){
        arr.push($(e).data('id'));
        $('#number').text(++n);
        $(e).attr('onclick','js_off(this)');
    }

    function js_off(e){
        $('#number').text(--n);
        for(let i=0;i<arr.length;i++){
            if(arr[i] == $(e).data('id')){
                arr.splice(i,1);
                break;
            }
        }
        $(e).attr('onclick','js_on(this)');
    }

    function js_tz(e){
        window.location .href = 'arrhomework4?id='+$(e).data('tzid');
    }

    function js_tj(){
        // for(let i=0;i<length;i++){
        //     arr.push($('.mb-subjects:eq('+i+')').data('id'));
        // }
        sessionStorage.setItem('dataid',arr);

         window.location.replace("/release");
    }
</script>
<!--flotdemo-->
{% endblock %}
